package com.eliza.library.dao

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.eliza.library.model.Contactor


/*-*- coding:utf-8 -*-
 * @Author  : debi
 * @Time    : 5/1/22
 * @Software: Android Condio
 */
@Database(entities = [Contactor::class], version = 1, exportSchema = true)
abstract class ContactorDatabase : RoomDatabase() {
    abstract val contactorDao: ContactorDao

    companion object {
        private const val DATABASE_FILE_NAME = "My_Contactor.db"
        private var mInstance: ContactorDatabase? = null

        @Synchronized
        fun getInstance(context: Context): ContactorDatabase {
            if (mInstance == null) {
                mInstance = Room.databaseBuilder(
                    context.applicationContext,
                    ContactorDatabase::class.java,
                    DATABASE_FILE_NAME
                ).build()
            }
            return mInstance as ContactorDatabase
        }
    }
}